(function($){

     //var privada = 'privado';
     $.fn.extend({ 
         
         //pass the options variable to the function
         imageload: function(el,options) {
            //Set the default values, use comma to separate the settings, example:
            var defaults = {
                imgTarget: 		'.lazy',
                captionTarget: 	'.caption',
                effectImg: 		'fadeIn',
            }
            //base
            var base = this;   
            //option default
            var options =  $.extend(defaults, options);
            
            // Access to jQuery and DOM versions of element
            base.$el = $(el);
            base.el = el;


            /**
            *Crei um novo elemento
            * @acess private
            */
            function createDiv() {
              //console.log( options.classCaption);
            }



            /**
            *Coloca um lasy loadin em uma imagens carregadas 
            *param  dependence imgTarget 
            * @acess private
            */
            function lasy(){
                 $("img"+ options.imgTarget).lazyload({
                    effect : options.effectImg,
                    placeholder : "img/loading.gif",
                    //failure_limit   : 10,
                    //container: $("#eventos")
                }); 
            }

            function caption(){
                 $("img"+options.imgTarget).each(function(i,ele) {  
                	 if(!!$(this).parent()){
                		 var width = $(this).parent().width();
                         $(this).next(options.captionTarget).css('width', width+'px');
                     }
                      //console.log($(this).next(".caption" ));
                 });
            }

            return this.each(function() {
                var o = options;
                lasy();
                caption();
              
                // base.createDiv();
            
            });
        },
        testeasdf: function () {
                 console.log(base);

        }
        

    });

})(jQuery);


